#include "ImageCoordinate.h"



ImageCoordinate::ImageCoordinate() : fixtureRow(0), fixtureCol(0), fovRow(0), fovCol(0) {}

ImageCoordinate::ImageCoordinate(int fr, int fc, int fvr, int fvc)
    : fixtureRow(fr), fixtureCol(fc), fovRow(fvr), fovCol(fvc) {}

QString ImageCoordinate::toString() const {
    return QString("F[%1,%2]_V[%3,%4]").arg(fixtureRow).arg(fixtureCol).arg(fovRow).arg(fovCol);
}

QJsonObject ImageCoordinate::toJson() const {
    QJsonObject obj;
    obj["fixtureRow"] = fixtureRow;
    obj["fixtureCol"] = fixtureCol;
    obj["fovRow"] = fovRow;
    obj["fovCol"] = fovCol;
    return obj;
}

ImageCoordinate ImageCoordinate::fromJson(const QJsonObject &json) {
    return ImageCoordinate(
        json["fixtureRow"].toInt(),
        json["fixtureCol"].toInt(),
        json["fovRow"].toInt(),
        json["fovCol"].toInt()
        );
}

ImageFileInfo::ImageFileInfo(const QString &orig, const QString &renamed, const QString &path, const ImageCoordinate &coord)
    : originalName(orig), renamedName(renamed), fullPath(path), coordinate(coord) {}

QJsonObject ImageFileInfo::toJson() const {
    QJsonObject obj;
    obj["originalName"] = originalName;
    obj["renamedName"] = renamedName;
    obj["fullPath"] = fullPath;
    obj["coordinate"] = coordinate.toJson();
    return obj;
}

ImageFileInfo ImageFileInfo::fromJson(const QJsonObject &json) {
    return ImageFileInfo(
        json["originalName"].toString(),
        json["renamedName"].toString(),
        json["fullPath"].toString(),
        ImageCoordinate::fromJson(json["coordinate"].toObject())
        );
}
